<?php

namespace App\Traits\Relation;

use App\Models\Demand;
use App\Models\Company;
use App\Models\Inspection\Circle;
use App\Models\Inspection\Line;
use App\Models\Inspection\Node;
use App\Models\Station;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

/**
 * 定义项目模型关联关系
 *
 * Trait ProjectRelation
 * @package App\Traits\Relation
 * Date: 25/04/2018
 * @author George
 */
trait ProjectRelation
{
	/**
	 * 获取项目所属公司
	 *
	 * Date: 11/04/2018
	 * @author George
	 * @return BelongsTo
	 */
	public function company()
	{
		return $this->belongsTo(Company::class, 'company_id', 'id');
	}

	/**
	 * 获取项目用人需求
	 *
	 * Date: 25/04/2018
	 * @author George
	 * @return HasMany
	 */
	public function demands()
	{
		return $this->hasMany(Demand::class, 'project_id', 'id');
	}

	/**
	 * 获取项目的巡检线路信息
	 *
	 * Date: 27/04/2018
	 * @author George
	 * @return HasMany
	 */
	public function lines()
	{
		return $this->hasMany(Line::class, 'project_id', 'id');
	}

	/**
	 * 获取项目的圈
	 *
	 * Date: 01/05/2018
	 * @author George
	 * @return HasMany
	 */
	public function circles()
	{
		return $this->hasMany(Circle::class, 'project_id', 'id');
	}

	/**
	 * 获取项目的巡检点
	 *
	 * Date: 01/05/2018
	 * @author George
	 * @return HasMany
	 */
	public function nodes()
	{
		return $this->hasMany(Node::class, 'project_id', 'id');
	}

	/**
	 * 获取项目岗点信息
	 *
	 * Date: 02/05/2018
	 * @author George
	 * @return HasMany
	 */
	public function stations()
	{
		return $this->hasMany(Station::class, 'project_id', 'id');
	}

	/**
	 * 获取岗点的时间设置
	 *
	 * Date: 02/05/2018
	 * @author George
	 * @return HasMany
	 */
	public function timings()
	{
		return $this->hasMany(Station\Timing::class, 'project_id', 'id');
	}
}
